﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/AdminSite.Master" Inherits="System.Web.Mvc.ViewPage<Veteran_cms.Models.core_user>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">
<!-- Validation form -->
<%using (Html.BeginForm("Create", "ManageUser", FormMethod.Post, new { enctype = "multipart/form-data", @class = "form", id = "validate" }))
    {
       %>
        
    <fieldset>
        <div class="widget">
            <div class="title"><img src="../../Images/adminSite/icons/dark/pencil.png" alt="" class="titleIcon" /><h6>Thông tin quản thành viên</h6></div>
            <div class="formRow">
                <label>Tên đăng nhập:<span class="req">*</span></label>
                 
                <div class="formRight"><%:Html.TextBoxFor(model => model.user_name, new { @class = "validate[required,custom[onlyLetterNumber]", id = "UserNameID", onblur = "return CheckName()" })%>
                <div id="dvUserName" style="visibility:collapse"> <span class="req"><label id="lbl"></label>: đã có người dùng</span></div>
                </div>
                <div class="clear"></div>
                
            </div>
            <div class="formRow">
                <label>Mật khẩu:<span class="req">*</span></label>
                <div class="formRight"><%:Html.PasswordFor(model => model.password, new { @class = "validate[required,minSize[6]]", id = "reg" })%>
               <div id="minlenght" style="visibility:collapse"><span class="req">Mật khẩu nhỏ nhất là 6 ký tự</span></div>
                </div>
               
                <div class="clear"></div>
            </div>
            <div class="formRow">
                <label>Nhập lại:<span class="req">*</span></label>
                 <div class="formRight"><%:Html.PasswordFor(model => model.ConfirmPassword, new { @class = "validate[required,equals[reg]]", id = "req" })%>
                  <div id="confirm" style="visibility:collapse"><span class="req"> Xác nhận không khớp</span></div>
                 </div>
                <div class="clear"></div>
            </div>
             <div class="formRow">
                <label>Email:<span class="req">*</span></label>
                <div class="formRight">  <%=Html.TextBoxFor(model => model.email, new { @class = "validate[required,custom[email]]", id = "EmailID",onblur="return CheckEmail()" })%>
                <div id="dvEmail" style="visibility:collapse"><span class="req"> <label id="lblEmail"></label>: đã có người dùng</span></div>
               </div>
                
                <div class="clear"></div>
            </div>
        </div>
        <div class="widget">
            <div class="formSubmit"><input type="submit" value="Lưu" class="blueB" /></div>
            <div class="clear"></div>
            <div><%:Html.HiddenFor(model => model.user_id)%></div>
        </div>
             
    </fieldset>
    <%} %>
    
    <script type="text/javascript">
       
        function CheckInput() {
           // var valid = true;
            var name = $("#UserNameID").val();
            $.post("/ManageUser/CheckName/", { username: name },
	                    function (data) {
	                        if (data === "True") {
	                            $('#dvUserName').css("visibility", "collapse");
	                        }
	                        else {
	                            $('#dvUserName').css("visibility", "visible");
	                            return false;
	                        }
	                    });
            var email = $("#EmailID").val();
            $.post("/ManageUser/CheckEmail/", { email: email },
	                    function (data) {
	                        if (data==="True") {
	                            $('#dvEmail').css("visibility", "collapse");

	                        }
	                        else {
	                            $('#dvEmail').css("visibility", "visible");
	                            return false;
	                        }
	                    });
            return true;
        }      
    
    </script>

    
    
	    <script type="text/javascript">

	        function CheckName() {
	            var name = $("#UserNameID").val();
	            $.post("/ManageUser/CheckName/", { username: name },
	                    function (data) {
	                        if (data === "True") {
	                            $('#dvUserName').css("visibility", "collapse");
	                            return true;
	                        }
	                        else {
	                            $('#dvUserName').css("visibility", "visible");
	                            document.getElementById('lbl').innerHTML = name;
	                            $("#UserNameID").val("");
	                            return false;
	                        }
	                    });
	        }
	        function CheckEmail() {
	            var email = $('#EmailID').val();
	            $.post("/ManageUser/CheckEmail/", { email: email },
	                    function (data) {
	                        if (data==="True") {
	                            $('#dvEmail').css("visibility", "collapse");
	                            return true;
	                        }
	                        else {
	                            $('#dvEmail').css("visibility", "visible");
	                            document.getElementById('lblEmail').innerHTML = email;
	                            $('#EmailID').val("");
	                            return false;
	                        }
	                    });
	        }
	        function RetypePassword() {
	            if ($('#PasswordID').val()!==$('#ConfirmPasswordID').val()) {
	                $('#confirm').css("visibility", "visible");
	                return false;
	            } else {
	                $('#confirm').css("visibility", "collapse");
	            }



	        }
	        function MinPassword() {
	            if ($('#PasswordID').val().toString()) {
	                if ($('#PasswordID').val().length < 6) {
	                    $('#minlenght').css("visibility", "visible");
	                    return false;
	                } else {
	                    $('#minlenght').css("visibility", "collapse");
	                }
	            }
	        }

	    </script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="TitleAreaPlaceHolder" runat="server">
</asp:Content>
